package com.java.base.exercise.designmode.single;

import java.util.concurrent.atomic.AtomicReference;

/**
 * @Author RenPu
 * @Date 2021/6/21 9:52
 * @Version 1.0
 * @Description:设计模式---单例设计模式V5.0 采用CAS实现单例模式
 **/
public class Single_005 {

    private static final AtomicReference<Single_005> instance=new AtomicReference();
    private Single_005(){}


    public  static Single_005 getInstance(){
        while (instance.get()==null){
            instance.compareAndSet(null,new Single_005());
        }
        return instance.get();

    }


}
